<?php
	$GLOBALS['libdb']->RQLQuery = 'lib/XDAL/rqlquery.php';
	
	class test_rql extends PHPUnit_TestCase {
		var $rql;
		
		function __construct($name) {
			$this->PHPUnit_TestCase($name);
		}
		
	    function test_class_available() {
        	$this->rql = new RQLQuery('self,$auth.');
	    	$this->assertType('object', $this->rql);
	    }
	    
	    function test_RQL_simple_translation() {
	    	$this->rql_translate_check('self,$auth.');
	    }
	    
	    function test_RQL_branch_translation() {
	    	$this->rql_translate_check('self, --<? group, --<& player; viewer; >--, user; group; >--, $auth.');
	    }
	    
	    
	    function rql_translate_check($query) {
	    	$this->rql = new RQLQuery($query);
			$sql = $this->rql->get_sql();
			echo ($sql.'<br/>');
        	$res = true; //mysqli_query($_SESSION['pconnect'], $sql);
        	$this->assertTrue($res, "Mysql query failed:\r\n\t".$sql."\r\n\t".mysqli_error($_SESSION['pconnect']));
	    }
	}
?>